package com.qf.controller;


import com.qf.pojo.req.XcHotelCityAreaReq;
import com.qf.pojo.req.XcHotelOrderReq;
import com.qf.pojo.resp.BaseResp;
import com.qf.service.HotelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value = "酒店接口",tags = "酒店接口")
@RequestMapping("/hotel")
@RestController
public class HotelController {

    @Autowired
    HotelService hotelService;

    //酒店首页,推荐酒店查询
    @ApiOperation("按酒店热度推荐酒店")
    @RequestMapping(value = "/recommendFind",method = RequestMethod.GET)
    public BaseResp recommendFind(){
        return hotelService.recommendFind ();
    }

    //查询城市
    @ApiOperation("查询城市")
    @RequestMapping(value = "/cityfind",method = RequestMethod.GET)
    public BaseResp cityfind(){
        return hotelService.cityFind();
    }

    //根据用户输入城市名查找对应的酒店大致信息
    @ApiOperation("查看当前城市的酒店信息")
    @RequestMapping(value = "/cityHotelName",method = RequestMethod.POST)
    public BaseResp cityHotelName(@RequestBody XcHotelCityAreaReq xcHotelCityAreaReq){
        return hotelService.cityHotelName(xcHotelCityAreaReq);
    }

    //点击酒店查询显示酒店详情
    @ApiOperation("点击酒店查询显示酒店详情，根据酒店id")
    @RequestMapping(value = "/hotelDetails/{hotelId}",method = RequestMethod.GET)
    public BaseResp hotelDetails(@PathVariable("hotelId")Integer hotelId){
        return hotelService.hotelDetails(hotelId);
    }

    //根据酒店不同房间类型点击预订并存入订单表中
    @ApiOperation("根据酒店不同房间类型点击预订并存入订单表中")
    @RequestMapping(value = "/hotelReserve",method = RequestMethod.POST)
    public BaseResp hotelReserve(@RequestBody XcHotelOrderReq xcHotelOrderResp, HttpServletRequest request){
        return hotelService.hotelReserve(xcHotelOrderResp,request);
    }

    //从数据库查询订单并展示
    @ApiOperation("从数据库查询订单并展示")
    @RequestMapping(value = "/hotelOrder",method = RequestMethod.GET)
    public BaseResp hotelOrder(HttpServletRequest request){
        return hotelService.hotelOrder(request);
    }

    //从数据库查询订单并展示
    @ApiOperation("从数据库查询所有订单包括已支付并展示")
    @RequestMapping(value = "/hotelOrderAll",method = RequestMethod.GET)
    public BaseResp hotelOrderAll(HttpServletRequest request){
        return hotelService.hotelOrderAll(request);
    }

    //取消订单
    @ApiOperation("根据订单号,取消订单")
    @RequestMapping(value = "/checkOut/{orderId}",method = RequestMethod.GET)
    public BaseResp checkOut(@PathVariable("orderId") String orderId){
        return hotelService.checkOut(orderId);

    }
}
